﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SAICAPPWEB.Models;
using DapperExtensions;
namespace SAICAPPWEB.BLL
{
    public class AppUserBll:BaseBll<AppUser>
    {
		public AppUser GetUserByPhoneNo(AppUser user)
		{
			IList<IPredicate> predList = new List<IPredicate>();
			predList.Add(Predicates.Field<AppUser>(p => p.PhoneNo, Operator.Eq, user.PhoneNo));
			IPredicateGroup ipg = Predicates.Group(GroupOperator.And, predList.ToArray());
	    	var	result = Db.GetList<AppUser>(ipg).FirstOrDefault();
			Db.Connection.Close ();
			return result;
		}
		public AppUser GetUserByToken(AppUser user)
		{
			IList<IPredicate> predList = new List<IPredicate>();
			predList.Add(Predicates.Field<AppUser>(p => p.PhoneNo, Operator.Eq, user.PhoneNo));
			predList.Add(Predicates.Field<AppUser>(p => p.PhoneSn, Operator.Eq, user.PhoneSn));
			IPredicateGroup ipg = Predicates.Group(GroupOperator.And, predList.ToArray());
			var	result = Db.GetList<AppUser>(ipg).FirstOrDefault();
			Db.Connection.Close ();
			return result;
		}
    }
}